import Dialog from '../../vant-weapp/dialog/dialog';
import Toast from '../../vant-weapp/toast/toast';
import fw from '../../core/framework.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data:null,
    dateData:[],
    info:[],
    infoType:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      data:JSON.parse(options.data)
    });
    wx.setNavigationBarTitle({
      title: this.data.data.name+'的活动日志'
    });
    this.setDate();
    this.setInfo();
    this.setInfoType();
  },
  setDate(){
    let currDate = new Date();
    let dateData = [{
      week:fw.moment(currDate).format('dddd').replace('星期',''),
      day:fw.moment(currDate).format('DD')|0,
      active:true
    }];
    for(var i=1;i<7;i++){
      dateData.push({
        week:fw.moment(currDate).add(-i,'day').format('dddd').replace('星期',''),
        day:fw.moment(currDate).add(-i,'day').format('DD')|0
      })
    }
    dateData = dateData.reverse();
    this.setData({
      dateData:dateData
    })
    console.log(dateData);
  },
  setInfoType(){
    this.setData({
      infoType:[
        {
          type:1,
            name:'睡眠',
            color:'#f57a25'
        },
        {
          type:2,
          name:'饮食',
          color:'#7ac143'
        },
        {
          type:3,
          name:'运动',
          color:'#00a78e'
        },
        {
          type:4,
          name:'外出',
          color:'#00bce4'
        },
        {
          type:5,
          name:'做家务',
          color:'#d8d8d8'
        }
      ]
    }) 
  },
  setInfo(){
    this.setData({
      info:[
        {
          type:1,
          name:'睡眠',
          color:'#f57a25',
          start:0,
          end:6,
          flex:6
        },{
          type:2,
          name:'饮食',
          color:'#7ac143',
          start:6,
          end:8,
          flex:2
        },{
          type:3,
          name:'运动',
          color:'#00a78e',
          start:8,
          end:11,
          flex:3
        },{
          type:2,
          name:'饮食',
          color:'#7ac143',
          start:11,
          end:13,
          flex:2
        },{
          type:4,
          name:'外出',
          color:'#00bce4',
          start:13,
          end:15,
          flex:2
        },{
          type:5,
          name:'做家务',
          color:'#d8d8d8',
          start:15,
          end:19,
          flex:4
        },{
          type:2,
          name:'饮食',
          color:'#7ac143',
          start:19,
          end:21,
          flex:2
        },{
          type:5,
          name:'做家务',
          color:'#d8d8d8',
          start:21,
          end:22,
          flex:1
        },{
          type:1,
          name:'睡眠',
          color:'#f57a25',
          start:22,
          end:24,
          flex:2
        }
      ]
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})